import js from '@eslint/js';
import tsParser from '@typescript-eslint/parser';
import prettier from 'eslint-plugin-prettier';
import simpleImportSort from 'eslint-plugin-simple-import-sort'; // 推荐排序
import pluginVue from 'eslint-plugin-vue';
import globals from 'globals';
import vueEslintParser from 'vue-eslint-parser';

export default [
    {
        languageOptions: {
            globals: {
                // 全局语言特性
                ...globals.browser,
                // Vue3 宏定义
                defineProps: 'readonly',
                defineEmits: 'readonly',
                defineExpose: 'readonly'
            }
        }
    },
    {
        files: ['**/*.{ts,vue}'],
        ignores: [
            '**/*.d.ts',
            'dist/**/*',
            'es/**/*',
            'lib/**/*',
            '.vitepress/cache/**/*',
            'node_modules/**/*'
        ],
        rules: {
            ...js.configs.recommended.rules,
            ...pluginVue.configs['vue2-strongly-recommended'].rules,
            semi: 'error',
            'prefer-const': 'error',
            'no-console': 'error',
            'vue/valid-define-emits': 'error',
            'simple-import-sort/imports': 'error',
            'simple-import-sort/exports': 'error'
        },
        languageOptions: {
            parser: vueEslintParser,
            parserOptions: {
                extraFileExtensions: ['.vue'],
                parser: tsParser
            }
        },
        plugins: {
            vue: pluginVue,
            'simple-import-sort': simpleImportSort,
            prettier: prettier
        }
    }
];
